from TextBadger.models import *
from xml.dom.minidom import parse
from django.conf import settings
import sys

def checkFile(codetext):
        return True

algos = Classifier_Algo.objects.filter(status=2)

for algo in algos:
	algo.status=3
	algo.save()

for algo in algos:
	print algo.id
	algofile = algo.filename.path
	
	try:
		# check code file for security issues
		code = open(algofile, "r").read()
		r = checkFile(code)
		if r == True:
			algo.status = 1
			algo.save()
		else:
			algo.status = 4
			algo.save()
	except:
		print sys.exc_type, ":", sys.exc_value
		print 'File Error. Marking this code file invalid'
		algo.status = 4
		algo.save()

